<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<title>新建企业分店账号</title>
<%@include file="../collect/meta.jsp"%>
<script src="${ctx}/js/md5.js"></script>
<script type="text/javascript" src="${ctx}/js/returnTop.js"></script>
<style type="text/css">
.tbinput {
	width: 180px;
	height: 30px;
	font-size: 16px;
	background-color: #FFFFCC;
}
</style>
<link rel="stylesheet" href="css/radius.css" type="text/css"></link>
<link rel="stylesheet" href="css/Inputstyle.css" type="text/css"></link>
<link rel="stylesheet" href="css/muser.css" type="text/css"></link>
</head>
<body lang="zh-cn">
	<div class="wrapper">
		<c:import url="/collect/top.jsp"></c:import>
		<div class="main-container" id="main-container">
			<div class="main-container-inner">
				<c:import url="/collect/left.jsp"></c:import>
				<div class="main-content">
					<div class="breadcrumbs" id="breadcrumbs">
						<ul class="breadcrumb">
							<li><i class="icon-home home-icon"></i>分店管理</li>
							<li><a href="muser!getAllUser">分店管理账号</a>
							</li>
							<li>创建管理账号</li>
						</ul>
						<!-- .breadcrumb -->
					</div>
					<div class="page-content">
						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->
								<form action="muser!addUser" name="adduser" method="post">
									<div align="center">
										<div class="common">
											<label for="one">登陆账号:&nbsp;</label> <input type="text"
												class="input" id="one" name="user.mobile" />
											<div id="contentone" class="cont1"></div>
										</div>
										<div class="common">
											<label for="one">&nbsp;&nbsp;&nbsp;&nbsp;姓名:&nbsp;</label> <input type="text"
												class="input" id="three" name="user.userName" />
											<div id="contentone" class="cont1"></div>
										</div>
										<div class="loginPassword">
											<label for="two">密码:&nbsp;</label> <input type="password" class="input"
												id="two" name="user.password" />
											<div id="contenttwo" class="cont2"></div>
										</div>
										<div class="common">
											<label for="">所属店铺:&nbsp;</label> <select name="user.shopId">
												<c:forEach items="${shops}" var="shop">
													<option value="${shop.id }">${shop.name }</option>
												</c:forEach>
											</select>
										</div>
										<div id="btn-team">
											<input type="button" class="btn btn-primary radius" id="but"
												value="添加" /> <a class="btn btn-primary radius"
												href="muser!getAllUser">返回</a>
										</div>
										<font style="color: red; font-size: 25px;">${result }</font>
									</div>
								</form>
								<!-- PAGE CONTENT ENDS -->
							</div>
							<!-- /.col -->
						</div>
						<!-- /.row -->
					</div>
					<!-- /.page-content -->
				</div>
				<!-- /.main-content -->
			</div>
			<!-- /.main-container-inner -->
			<a href="#" id="btn-scroll-up"
				class="btn-scroll-up btn btn-sm btn-inverse"
				style="position:fixed;bottom:0;"> <i
				class="icon-double-angle-up icon-only bigger-110"></i> </a>
		</div>
		<!-- /.main-container -->
		<div class="push"></div>
	</div>
	<c:import url="/collect/down.jsp"></c:import>
	<script type="text/javascript">
		$(document).ready(function() {
			var sub1 = false;
			var sub2 = false;

			$("input[id='one']").blur(function() {
				var mobile = $(this).val();
				if (mobile.length == 0) {
					$("#contentone").html("");
					$("#contentone").html("请输入账号");
					sub1 = false;
				} else {
					$("#contentone").html("");
					sub1 = true;
				}

				if (!sub1)
					return false;

				$.ajax({
					url : "member!checkMobile",
					type : "post",
					data : {
						"mobile" : mobile
					},
					datatype : "json",
					success : function(data) {
						var d = eval("(" + data + ")");
						if (d != null) {
							if (d.isCheck) {
								$("#contentone").html("");
								$("#contentone").html("账号已被注册");
								sub1 = false;
							} else {
								$("#contenttwo").html("");
								sub1 = true;
							}
						}
					},
					error : function(request) {
						alert("Connection error");
					}
				});

			}).focus(function(){
				$("#contentone").html("");
			});

			$("input[id='two']").blur(function() {
				var password = $(this).val();
				if (password.length == 0) {
					$("#contenttwo").html("");
					$("#contenttwo").html("请输入密码");
					sub2 = false;
				} else {
					$("#contenttwo").html("");
					sub2 = true;
				}

				if (!sub2)
					return false;
			}).focus(function(){
				$("#contenttwo").html("");
			});

			$("#but").click(function() {
				var shopId = $("select[name='user.shopId']").val();
				if (shopId == null || shopId == '') {
					alert("请您先创建分店！");
					return false;
				}

				if (sub1 && sub2) {
					$("#two").val(faultylabs.MD5($("#two").val()));
					adduser.submit();
				} else {
					alert("请完善以上信息");
					return false;
				}
			});

			//防dropmenu刷新收回($企业分店：$创建管理账号)
			$(document).ready(function() {
				$('.fendianguanli > ul').show();
				$('.fendianguanli > ul > li > a').eq(1).css("color", "red");
			});
		});
	</script>
</body>
</html>